import axios from 'axios';

class Service {
    static listDishes(baseQuery, callback) {
        return axios.post("/manage-api/list-dish", baseQuery).then((data) => {
            callback ? callback(data) : null;
        })
    }

    static detail(id, callback) {
        return axios.get("/manage-api/dish/" + id).then((data) => {
            callback ? callback(data) : null;
        })
    }

    static update(dish, callback) {
        return axios.put("/manage-api/dish", dish).then((data) => {
            callback ? callback(data) : null;
        })
    }

    static listDeviceTypeAndSpec(callback) {
        return axios.all([axios.get("/manage-api/device-type"), axios.get("/manage-api/dish-spec")]).then(
            axios.spread(function (types, specs) {
                callback ? callback(types, specs) : null;
            })
        );
    }

    static allDishes(callback) {
        return axios.get("/manage-api/all-dish").then((data) => {
            callback ? callback(data) : null;
        })
    }
}

export default Service;